package ipad.asia.controller;

import ipad.asia.dao.ShopDao;
import ipad.asia.entity.Enterprise;
import ipad.asia.entity.Shop;
import ipad.asia.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ShopController {
    @Autowired
    private ShopService shopService;
    @Autowired
    private ShopDao shopDao;
    /**
     * 根据id查找店铺，用于聊天中的咨询商家
     * @param id
     * @return
     */
    @RequestMapping("/shop/getById")
    public Shop findById(@RequestParam(value = "id",required = false) int id) {
        return shopDao.findById(id);
    }

    /**
     * 根据模糊搜索店铺名查找店铺，用于顾客
     * @param name
     * @return
     */
    @RequestMapping("/shop/getByName/{name}")
    public List<Shop> findByNameLike(@PathVariable(value = "name",required = false) String name) {
        return shopDao.findByNameLike(name);
    }
    /**
     * 根据商家id查找店铺，用于商家
     * @param id
     * @return
     */
    @RequestMapping("/shop/getByEnterpriseId")
    public Shop findByEnterpriseId(@RequestParam(value = "int") int id) {
        return shopDao.findByEnterpriseId(id);
    }
}
